<?php
defined('IN_MAIN') or exit('Invalid Access!');

function build_stockist($country, $state, $selected, $name, $extra=""){
/*
This function will build a select box consisting of all the stockists within the country and state
*/

global $vars;
$db=$vars["db"];

$r_stockist[0]="";
$r_stockist_d[""]=__("Please select a stockist");
$t=@mysql_num_rows($r=mysql_query("select id, name, city from $db->stockists where country='$country' and state='$state' and status='normal' order by name"));
for($i=0;$i<$t;$i++){
 $stockist=mysql_fetch_assoc($r);
 $r_stockist[($i+1)]=$stockist["id"];
 $r_stockist_d[$stockist["id"]]=__("ID").__(":")."  $stockist[id], $stockist[name], $stockist[city]";
}
return build_select($r_stockist, $r_stockist_d, $selected, $name, $extra);
}
?>